<?php use_Helper("jQuery"); ?>
<?php slot('catalog_menu') ?>
<?php include_component('catalog','categorymenu', array('expand'=>isset($allcats))) ?>
<?php end_slot() ?>



<?php
slot('breadcrumbs');

echo link_to('Каталог','catalog/index').' / ';

if(isset($cats))
{
ksort($cats);
$curcat = current($cats);
krsort($cats);
	foreach($cats as $cat)
	{				
		if($curcat != $cat->getTitle())
			echo link_to($cat->getTitle(),'catalog/index?catid='.$cat->getId()	).' / ';
		else echo $cat->getTitle();
	}
}	
end_slot();	
?>

<script type='text/javascript'>
function showpath()
{
<?php
if(isset($cats))
{
reset($cats);
if(count($cats))
	foreach($cats as $cat)
	{
		echo '$("#menu'.$cat->getId().'").show();';
	}
end($cats);	
echo '$("#spanmenu'.current($cats)->getId().'").css("font-weight","bolder");';
}
?>
}
</script>

<div style="padding-bottom: 10px; width:497px; height:63px; background: transparent url('/images/filters_bg.gif') scroll no-repeat">
<select id="regid" onchange="window.location = '<?php echo url_for('catalog/index').'?catid='.(isset($cats)? current($cats)->getId() : null).( $sort=='DESC' ? '&sort=ASC' : '&sort=DESC').'&r_id=' ?>'+$('#regid').val() ;" name="region" size="1" style="margin:34px 0 0 10px">
<option value="-1">Все регионы</option>
<?php foreach($allregions as $reg) { ?>
<option value="<?php echo $reg->getId() ?>" <?php if($reg->getId() == $region_id ) echo 'selected' ; ?> ><?php echo $reg ?></option>
<?php } ?>
</select>
</div>

<?php if(count($pager->getResults())) { ?>
<table class='myproduct_table' style='width: 700px'>
	<tr>
		<th>Продавец</th>
		<th>Наименование товара - артикул</th>
		<th><?php echo link_to('Цена, грн','catalog/index?catid='.(isset($cats) ? current($cats)->getId() : null).( $sort=='DESC' ? '&sort=ASC' : '&sort=DESC')).'<span style="font-size:14px">'.($sort=='DESC'? ' &uarr' : ' &darr').'</span>' ?></th>
		<th>Цена, $</th>
	</tr>
	<?php
	
	foreach($pager->getResults() as $prod) { ?>
	<tr>
		<td style='text-align: center'><?php include_partial('catalog/account', array('user' => $prod['SfGuardUser'])) ?></td>
		<td style='padding-left:10px; font-size:14px'><?php echo link_to($prod['title'], 'catalog_showrpoduct', array('id'=>$prod->getId()) ).' - '.$prod['artikul'] ?></td>
		<td align='center' style='color:#369; font-size:14px'><?php echo sprintf('%0.2f', $prod['price']==NULL ? $prod['price_usd']*$course : $prod['price']) ?></td>
		<td align='center' style='color:#369; font-size:14px'><?php echo sprintf('%0.2f$', $prod['price_usd']==NULL ? $prod['price']/$course : $prod['price_usd']) ?></td>
	</tr>
	<?php } ?>
</table>
<?php }
else echo 'В данной категории пока нет товаров, вы можете добавить свое предложение, зайдя на страницу зарузки прайс-листов'; ?>

<div style='clear:both'></div>

<div style='text-align:right; padding:10px;'>
<?php if($pager->haveToPaginate()){
	// first arrow
	if ($pager->getPage()>1)
	echo link_to("&larr; ",'catalog/index?page='.($pager->getPage()-1). ( isset($cats) ? '&catid='.$curcat->getId() : NULL )  ,array('style' => 'text-decoration:none'));
	else echo '&larr; ';
	
for ($i=1; $i<=$pager->getLastPage(); $i++)
{
	echo $i != $pager->getPage() ? link_to("$i ",'catalog/index?page='.$i. ( isset($cats) ? '&catid='.$curcat->getId() : NULL )  ,array('style' => 'text-decoration:none')) : "$i ";
}
	
	// last arrow
	if ($pager->getPage()<$pager->getLastPage())
	echo link_to("&rarr; ",'catalog/index?page='.($pager->getPage()+1). ( isset($cats) ? '&catid='.$curcat->getId() : NULL )  ,array('style' => 'text-decoration:none'));
	else echo '&rarr;';
} ?>
</div>